cimport c_cxcore
cimport cy_cvtypes
    
def cvCreateImage(size, depth, channels):
    ''' cvCreateImage((width, height), depth, channels)
    size should be a tuple of python ints
    depth should be an OpenCV depth constant (IPL_DEPTH_8U for example)
    channels should be 1,2,3 or 4
    returns an IplImage '''
    cdef int c_depth = depth
    cdef int c_channels = channels    
    cdef cy_cvtypes.IplImage py_img = cy_cvtypes.IplImage()
    cdef c_cxcore.CvSize c_size = c_cxcore.cvSize(size[0], size[1])
    cdef c_cxcore.IplImage* c_img
    with nogil:
        c_img = c_cxcore.cvCreateImage(c_size, c_depth, c_channels)
    py_img.thisptr = c_img
    return py_img
    
def cvReleaseImage(cy_cvtypes.IplImage image):
    raise NotImplementedError('Memory Management is taken care of by the wrapper')
    
def cvCloneImage(cy_cvtypes.IplImage image):
    cdef c_cxcore.IplImage* c_img = image.thisptr
    cdef c_cxcore.IplImage* c_outimg 
    cdef cy_cvtypes.IplImage py_outimg = cy_cvtypes.IplImage()
    with nogil:
        c_outimg = c_cxcore.cvCloneImage(c_img)
    py_outimg.thisptr = c_outimg
    return py_outimg
    

    

